<template>
  <div>
    <Form :model="form"  lable="80">
      <FormItem lable="书名称" >
        <Input v-model="form.name" style="width: 350px" placeholder="请输入书名称"></Input>
      </FormItem>
      <FormItem  lable="作者">
        <Input v-model="form.author" placeholder="请输入作者名称" style="width: 350px"></Input>
      </FormItem>
      <FormItem lable="出版社" >
        <Input v-model="form.publish" placeholder="请输入出版社名称" style="width: 350px"></Input>
      </FormItem>
      <FormItem lable="标准书号" >
        <Input v-model="form.isbn" placeholder="请输入标准书号" style="width: 350px"></Input>
      </FormItem>
      <FormItem lable="书的介绍" >
        <Input v-model="form.introduction" placeholder="请输入输的介绍" style="width: 350px"></Input>
      </FormItem>
      <FormItem lable="语言" >
        <Input v-model="form.language" placeholder="请输入语言" style="width: 350px"></Input>
      </FormItem>
      <FormItem lable="价格信息" >
        <Input v-model="form.price" placeholder="请输入价格信息" style="width: 350px"></Input>
      </FormItem>
      <FormItem lable="出版时间" >
        <DatePicker v-model="form.pub_date" type="date" placeholder="请选择出版时间"></DatePicker>
      </FormItem>
      <FormItem lable="图书类型" prop="type_id">
        <Select v-model="form.type_id" style="width: 350px" prop="type_id">
          <Option v-for="item in typeList" :value="item.name"  :key="item.name">{{ item.name }}
          </Option>
        </Select>
      </FormItem>
      <FormItem>
        <Button @click="add" style="margin: 5px" type="primary">提交</Button>
        <Button @click="quxiao">取消</Button>
      </FormItem>
    </Form>
  </div>
</template>

<script>
export default {
  name: "UpdateBook",
  props:['data'],
  data(){
    return{
      form:[],
    }
  },
  methods:{
    add(){
      this.form.pub_date=(new Date(this.form.pub_date)).toLocaleDateString()
      this.http.post("updateInformation",this.qs.parse(this.form)).then(res=>{
        if (res.data){
          this.$Message.success('修改成功');
          this.$emit("hideDialog")
          this.$emit("after")
        }else {
          this.$Message.error('修改失败')
        }
      })
    },
    quxiao(){
      this.$emit("hideDialog")
    }
  },
  created() {
    this.form=this.data;
    console.log(this.type)
  },
  computed:{
    typeList(){
      return this.$store.state.type
    }
  }
}
</script>

<style scoped>

</style>
